using System;

using EMan.Common.DependencyInjection;
using EMan.Interface.Common;

using TrueCode.Core.Aspects;

namespace EMan.GUI.Common
{
  public class BaseViewUserControl< TPresenter, TView > : BaseViewUserControl
    where TView : IView
    where TPresenter : class, IPresenter< TView >
  {
    private readonly TPresenter _presenter;

    protected BaseViewUserControl( [NotNull] IFactory factory, [NotNull]TPresenter presenter ) : base(factory)
    {
      if( presenter == null ) throw new ArgumentNullException( "presenter" );

      _presenter = presenter;

      DataContext = presenter.DataContext;
      presenter.View = (TView)(object)this;
    }

    protected TPresenter Presenter
    {
      get { return _presenter; }
    }

    #region Implementation of IView
    #endregion

    #region Private
    #endregion

    [Obsolete("Do not use this contstructor, it is for WPF designer only")]
    protected BaseViewUserControl(){}
  }
}